#include"udp_server.hpp"
#include<iostream>
#include<unordered_map>
#include<cstdlib>

std::unordered_map<std::string,std::string> dict;

void Translate(std::string req,std::string* resp){
    auto it=dict.find(req);
    if(it==dict.end()){
        *resp="未找到这个单词";
        return;
    }
    *resp=it->second;
}
int main(int argc,char* argv[])
{
    if(argc!=2){
        std::cout<<"usage: ./udpserver server_port\n";
        return -1;
    }
    dict.insert({"hello","你好"});
    dict.insert({"apple","苹果"});
    dict.insert({"banana","香蕉"});
    dict.insert({"orange","橘子"});

    UdpServer server;
    server.start(atoi(argv[1]),Translate);
    return 0;
}